<template>
    <i-table border ref="selection" :columns="fdTableColumns" :data="fdTableData" 
    @on-selection-change="itemSelect" @on-select-all="itemSelectAll"></i-table>
</template>

<script>
export default {
  data() {
    return {
      fdTableColumns:[
        {
            type: 'selection',
            width: 60,
        },
        {
            type: 'index',
            width: 60,
            align: 'center',
            render (h, params){
                return params.index +1 ;
            }
        },
        {
          title:'id',
          key:'fdId',
        },    
        {
          title: '流程名称',
          key: 'fdName'
        },
        {
          title: '操作',
          key: 'action',
          render: (h, params) => {
                return h('div', [
                    h('Button', {
                        props: {
                            type: 'primary',
                            size: 'small'
                        },
                        style: {
                            marginRight: '5px'
                        },
                        on: {
                            click: () => {
                                this.flowStart(params.row.fdId)
                            }
                        }
                    }, '启动')
                ]);
          }
        }
      ],
      fdTableData: []
    };
  },
  created() {
    
  },
  mounted() {
    this.getAllPd();
  },
  methods: {
    getAllPd() {
      this.$http
        .post("/flow/fd/getAllPd")
        .then(res => {
          if(res.retHead.code == '0000000'){
            for(var idx in res.retBody){
                 this.fdTableData.push({
                     fdId: res.retBody[idx].fdId,
                     fdName: res.retBody[idx].fdName
                 });
            }
            console.log(this.fdTableData);
          }
        });
    },
    
    flowStart(procDefId){
        console.log('流程启动');
        this.$router.push({
            name: 'start-leave-app',
            params:{
                procDefId: procDefId
            }
        });
    },

    itemSelect(selection){
        console.log(selection);
    },

    itemSelectAll(selection){

        console.log("itemSelectAll");

        console.log(selection);

    }


  }
};
</script>

